First Class Function
- Function can be used as value like storing in variable, passing as arguments, returning as value.
HOF
High Order Function is a function that either:
- takes one or more functions as arguments.
- returns a function as its result.
Common HOF in Javascript:
Custom HOF
Example:
const performOperation = (operation) => {
console.log("Operation Request Accepted");
return operation;
};
const add = (a, b) => {
return a + b;
};
const addOperation = performOperation(add);
console.log(addOperation(4, 5));
performOperation is a HOF